﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ViewRessources="clr-namespace:Tagomatique.View.TemplateSelector"
                    xmlns:models="clr-namespace:Tagomatique.Models;assembly=Tagomatique.Models">
    <Style x:Key="GroupedTagListBoxStyle" TargetType="ListBox">
        <Style.Resources>
            <Style TargetType="ListBoxItem">
                <Style.Resources>
                    <!-- SelectedItem with focus -->
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
                    <!-- SelectedItem without focus -->
                    <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
                    <!-- SelectedItem text foreground -->
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
                </Style.Resources>
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            </Style>
        </Style.Resources>
        
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <WrapPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate DataType="models:GroupedTagViewModel">
                    <TextBlock>
                        <Hyperlink Command="{Binding Command}" CommandParameter="{Binding .}">
                            <TextBlock Text="{Binding Libelle}" FontSize="{Binding TexteSize}" />
                        </Hyperlink>
                    </TextBlock>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MediaListBoxStyle" TargetType="ListBox">
        <Style.Resources>
            <DataTemplate x:Key="stringTemplate" DataType="models:MediaViewModel">
                <TextBlock Width="80" Height="80" Text="{Binding Nom}" TextWrapping="WrapWithOverflow" />
            </DataTemplate>

            <DataTemplate x:Key="pictureTemplate" DataType="models:MediaViewModel">
                <Image Width="80" Height="80" Source="{Binding Path=Thumbnail, Mode=OneWay, IsAsync=True}" Stretch="Uniform" />
            </DataTemplate>
        </Style.Resources>

        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <WrapPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplateSelector">
            <Setter.Value>
                <ViewRessources:MediaTemplateSelector PictureTemplate="{StaticResource pictureTemplate}"
                                                      StringTemplate="{StaticResource stringTemplate}" />
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>